
from Planet import *
from Ksink import *

class Star:
	def __init__(self, x_, y_, list_, name_):
		self.x = x_
		self.y = y_
		self.pos = (x_, y_)
		self.name = name_
		self.closest = checkClosest(x_, y_, list_, 5)
		self.planets = []
		numPlanets = randint(1,8)
		p = 1
		while p <= numPlanets:
			planetName = addNumeral(p, self.name)
			self.planets.append(Planet(planetName))
			p += 1
	def getX(self):
		return self.x

	def getY(self):
		return self.y


		
def checkClosest(x_, y_, list_, dist_):
	closest = None
	last = 1000
	for pos in list_:
		tX = x_ - pos[0]
		tY = y_ - pos[1]
		total = abs(tX) + abs(tY)
		if total <= last:
			if (x_, y_) != (pos[0], pos[1]):
				last = total
				closest = pos
			else:
				pass
			
	return closest

